#include "agencyevent.h"
#include <sstream>


template<typename T>
static std::string ToGroupString(const T& group, const std::string& sep = ",")
{
    std::stringstream ss;
    bool is_first = true;
    for (auto item : group)
    {
        if (is_first)
        {
            is_first = false;
        }
        else
        {
            ss << sep;
        }
        ss << item;
    }
    return ss.str();
}

void stAgencyEvent::CopyFrom(const agency_event_proto::AgencyEvent& that)
{
    this->agency_id = that.agency_id();
    this->call_url = that.call_url();
    this->state = that.state();
    this->gamelist.clear();
    for (auto& item : that.gamelist())
    {
        this->gamelist.emplace(item);
    }
    this->ext = that.ext();
    this->currency = that.currency();
    this->currency_unit_multi = that.currency_unit_multi();
    this->agency_name = that.agency_name();
}
void stAgencyEvent::CopyTo(agency_event_proto::AgencyEvent& that) const
{
    that.set_agency_id(this->agency_id);
    that.set_call_url(this->call_url);
    that.set_state(this->state);
    for (auto& item : this->gamelist)
    {
        that.add_gamelist(item);
    }
    that.set_ext(this->ext);
    that.set_currency_unit_multi(this->currency_unit_multi);
    that.set_currency(this->currency);
    that.set_agency_name(this->agency_name);
}

stAgencyEvent& stAgencyEvent::operator = (const stAgencyEvent& that)
{
    this->agency_id = that.agency_id;
    this->call_url = that.call_url;
    this->gamelist = that.gamelist;
    this->state = that.state;
    this->ext = that.ext;
    this->currency = that.currency;
    this->currency_unit_multi = that.currency_unit_multi;
    this->agency_name = that.agency_name;
    return *this;
}
stAgencyEvent& stAgencyEvent::operator = (stAgencyEvent&& that)
{
    this->agency_id = std::move(that.agency_id);
    this->call_url = std::move(that.call_url);
    this->gamelist = std::move(that.gamelist);
    this->state = std::move(that.state);
    this->ext = std::move(that.ext);
    this->currency = std::move(that.currency);
    this->currency_unit_multi = std::move(that.currency_unit_multi);
    this->agency_name = std::move(that.agency_name);
    return *this;
}

std::string stAgencyEvent::ToString() const
{
    std::stringstream ss;
    ss << "{" 
        << "agency_id:" << this->agency_id << ","
        << "call_url:" << this->call_url << ","
        << "gamelist:" << ToGroupString(this->gamelist) << ","
        << "state:" << this->state << ","
        << "ext:" << this->ext << ","
        << "currency:" << this->currency << ","
        << "currency_unit_multi:" << this->currency_unit_multi << ","
        << "agency_name:" << this->agency_name
    << "}";

    return ss.str();
}







